package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.constant.RedisConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import com.itheima.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import redis.clients.jedis.JedisPool;

import java.io.IOException;
import java.util.List;
import java.util.UUID;

/*
类简介：

功能：

时间：2020/4/2

*/
@Controller
@RequestMapping("/setmeal")
@ResponseBody
public class SetMealController {

    @Reference
    private SetmealService setmealService;

    @RequestMapping("/getAllSetmeal")
    public Result pageQuery(){
        List<Setmeal> setmeals;
        try {
            setmeals = setmealService.getAllSetmeal();
        }catch (Exception e){
            return new Result(true,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
        return new Result(true,MessageConstant.GET_SETMEAL_LIST_SUCCESS,setmeals);
    }

    @RequestMapping("/findById")
    public Result findById(int id){
        Setmeal setmeal;
        try {
            setmeal = setmealService.findById(id);
        }catch (Exception e){
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
        return new Result(true,MessageConstant.GET_SETMEAL_LIST_SUCCESS,setmeal);
    }
}
